/**
 * socket.h Header file
 * (C) Nettle developers 2000-2001
 *
 * $Id: socket,v 1.14 2004/04/13 20:30:56 archifishal Exp $
 */

#ifndef SOCKET_H
#define SOCKET_H

#ifndef Resolver_GetHost
#define Resolver_GetHost   0x46001
#endif

#define RESOLVER_FAILED		0
#define RESOLVER_INPROGRESS	1
#define RESOLVER_SUCCESS	2

extern int socket_connecttoip(unsigned long, int);
extern void socket_close(int);
extern int socket_readdata(int,char *,int);
extern int socket_senddata(int /*socket*/, const char */*buffer*/,
                           int /*length*/);
extern char *socket_ip_string(unsigned long);


/**
 * Test whether an inprogress connect is finished yet
 *
 * @param socket_handle   Socket to check
 *
 * @return -1    => connect still in progress
 *          0    => connected
 *         other => failed to connect, return value is socket error
 */
int socket_connected(int socket_handle);

/**
 * Tries to convert a port name (eg. pop3) into a numeric one
 *
 * @param port_name string containing port name
 *
 * @return port number, or 0 if unknown
 */

int socket_port_number_from_name(const char *port_name);

/**
 * Convert socket errno to string explanation
 *
 * Note: uses an internal static array to make a string for any unknown
 * error numbers.
 *
 * @param errnum   Value of 'errno' to be converted
 *
 * @return textual representation of error
 */
const char *socket_strerror(int errnum);



#endif
